<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var num = parseInt(prompt("输入一个偶数"));
        isTrue(num);

        // 判断一个数是否是质数
        function factorial(a) {
            var sum = 0;
            for (var i = 1; i <= a; i++) {
                if (a % i == 0) {
                    sum++;
                }
            }
            if (sum == 2) {
                return true;
            } else {
                return false;
            }
        }
        // 判断用户输入的偶数是否可分为两个质数之和：

        function isTrue(a) {
            for (var i = 2; i < a - 2; i++) {
                var j = a - i;
                if (factorial(i) && factorial(j)) {
                    console.log(a + "可以拆分为两个质数" + i + "与" + j + "的和");
                }
            }
        }
    </script>
</body>

</html>